package cn.csxw.openchina.ui.fragment.myFragment;

import android.os.Bundle;
import android.support.annotation.Nullable;

import javax.inject.Inject;

import cn.csxw.openchina.base.BaseRecAdapter;
import cn.csxw.openchina.base.BaseRefreshFragment;
import cn.csxw.openchina.constant.Constant;
import cn.csxw.openchina.dagger2.component.DaggerMyBlogFragmnetComponent;
import cn.csxw.openchina.dagger2.module.MyBlogModule;
import cn.csxw.openchina.dagger2.presenter.MyBlogFragmentPresenter;
import cn.csxw.openchina.ui.adapter.MyBlogAdapter;
import cn.csxw.openchina.utils.Global;

/**
 * Created by hp on 2017/1/18.
 */

public class MyBlogFragment extends BaseRefreshFragment {
    @Inject
    MyBlogFragmentPresenter mMyBlogFragmentPresenter;
    public MyBlogAdapter mMyBlogAdapter;

    @Override
    protected BaseRecAdapter getAdapter() {
        if(mMyBlogAdapter==null){
            mMyBlogAdapter = new MyBlogAdapter();
        }
        return mMyBlogAdapter;
    }

    @Override
    public void doRefresh() {
        mMyBlogAdapter.getData().clear();
        mMyBlogFragmentPresenter.callNetWork(Global.getUserUid(Constant.USER_UID), Global.getUserUid(Constant.USER_UID)
                , 0, "wgc03", 20);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        DaggerMyBlogFragmnetComponent.builder().myBlogModule(new MyBlogModule(this))
                .build().inject(this);
        Global.onNetworkStateListener(mMyBlogFragmentPresenter,this);
        mMyBlogFragmentPresenter.callNetWork(Global.getUserUid(Constant.USER_UID), Global.getUserUid(Constant.USER_UID)
                , 0, "wgc03", 20);
    }
}
